package com.example.zhilongzhang.constructionpayapp.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.example.zhilongzhang.constructionpayapp.base.App;

public class SpUtil {

    private static final String PREF_NAME = "pref_user";

    private static final Context sContext = App.getInstance();

    // ----------------以下为全局信息缓存-----------------------

    public static String getUserName() {
        SharedPreferences sp = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sp.getString("userName", "");
    }

    public static void setUserName(String userName) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit();
        editor.putString("userName", userName).apply();
    }

    public static String getPassword() {
        SharedPreferences sp = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sp.getString("password", "");
    }

    public static void setPassword(String password) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit();
        editor.putString("password", password).apply();
    }
    public static String getToken() {
        SharedPreferences sp = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sp.getString("token", "");
    }
    public static void setToken(String password) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit();
        editor.putString("token", password).apply();
    }
    public static boolean getDaYin() {
        SharedPreferences sp = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
        return sp.getBoolean("DaYin", true);
    }
    public static void setDaYin(boolean isDY) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE).edit();
        editor.putBoolean("DaYin", isDY).apply();
    }

    // ----------------以下为用户信息缓存-----------------------
    public static String getName() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("name", "");
    }

    public static void setName(String name) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("name", name).apply();
    }
    public static String getShopId() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("shopid", "");
    }

    public static void setShopId(String password) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("shopid", password).apply();
    }
    public static String getShopName() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("shopname", "");
    }

    public static void setShopName(String password) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("shopname", password).apply();
    }
    public static String getTel() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("tel", "");
    }

    public static void setTel(String password) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("tel", password).apply();
    }
    public static String getUserId() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("userId", "");
    }

    public static void setUserId(String userId) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("userId", userId).apply();
    }
    public static String getType() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("Type", "");
    }

    public static void setType(String Type) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("Type", Type).apply();
    }
    public static String getGSDM() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("GSDM", "");
    }

    public static void setGSDM(String GSDM) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("GSDM", GSDM).apply();
    }
    public static String getShopSearUrl() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("shopSearUrl", "");
    }

    public static void setShopSearUrl(String shopUrl) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("shopSearUrl", shopUrl).apply();
    }
    public static String getShopAddUrl() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("shopAddUrl", "");
    }

    public static void setShopAddUrl(String shopUrl) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("shopAddUrl", shopUrl).apply();
    }
    public static String getQRImgUrl() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("QRImgUrl", "");
    }

    public static void setQRImgUrl(String shopUrl) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("QRImgUrl", shopUrl).apply();
    }
    public static String getQRPayUrl() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("QRPayUrl", "");
    }

    public static void setQRPayUrl(String shopUrl) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("QRPayUrl", shopUrl).apply();
    }
    public static String getListImg() {
        SharedPreferences sp = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE);
        return sp.getString("ListImg", "");
    }

    public static void setListImg(String ListImg) {
        SharedPreferences.Editor editor = sContext.getSharedPreferences(getUserName(), Context.MODE_PRIVATE).edit();
        editor.putString("ListImg", ListImg).apply();
    }

}
